package com.indusfo.spc.client.controller;

import com.indusfo.spc.annotation.UserLoginToken;
import com.indusfo.spc.client.pojo.ClientBatchFinish;
import com.indusfo.spc.client.service.ClientBatchFinishService;
import com.indusfo.spc.vo.JSONObject;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhengd
 * @create 2019-12-04
 */
@RestController
@RequestMapping("/client/batchFinish")
public class ClientBatchFinishController {

	@Autowired
	private ClientBatchFinishService clientBatchFinishService;

	/**
	 * 客户端批次报工新增
	 * 
	 * @param ClientBatchFinish
	 * @return
	 */
	@PostMapping("/saveClientBatchFinish")
	@UserLoginToken
	public JSONObject saveClientBatchFinish(@RequestBody ClientBatchFinish clientBatchFinish) {
		return JSONObject.oK(clientBatchFinishService.saveClientBatchFinish(clientBatchFinish));
	}

	/**
	 * 客户端批次报工根据批号查询基本信息
	 * 
	 * @param batchCode
	 * @return
	 */
	@PostMapping("/queryClientBatchFinishByBatchCode")
	@UserLoginToken
	public JSONObject queryClientBatchFinishByBatchCode(@RequestBody Map<String, String> map) {
		return JSONObject.oK(clientBatchFinishService.queryClientBatchFinishByBatchCode(map.get("batchCode")));
	}

	/**
	 * 根据任务单ID查询已报工数量
	 * 
	 * @param orderId
	 * @return
	 */
	@PostMapping("/queryClientFinishNumByOrderId")
	@UserLoginToken
	public JSONObject queryClientFinishNumByOrderId(@RequestBody Map<String, Integer> map) {
		return JSONObject.oK(clientBatchFinishService.queryClientFinishNumByOrderId(map.get("orderId")));
	}

	/**
	 * 客户端批次报工查询当天报工信息
	 * 
	 * @param
	 * @return
	 */
	@PostMapping("/queryClientBatchFinishByCreateDate")
	@UserLoginToken
	public JSONObject queryClientBatchFinishByCreateDate() {
		return JSONObject.oK(clientBatchFinishService.queryClientBatchFinishByCreateDate());
	}
}
